package cn.baiweigang.uu.service.fetch;

import cn.baiweigang.uu.db.dataobj.StockInfoDo;
import cn.baiweigang.uu.db.repository.BaseInfoRepository;
import cn.baiweigang.uu.db.repository.HistoryDayInfoRepository;
import cn.baiweigang.uu.service.okhttp.HttpService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public abstract class FetchBaseService {
    @Autowired
    protected HttpService httpService;

    @Autowired
    protected HistoryDayInfoRepository historyDayInfoRepository;

    @Autowired
    protected BaseInfoRepository baseInfoRepository;

    protected boolean isST(StockInfoDo stockInfoDo) {
        return stockInfoDo.getMc().indexOf("ST") > -1 ||
                stockInfoDo.getMc().indexOf("st") > -1 ||
                stockInfoDo.getMc().indexOf("退市") > -1;
    }

    //分页查询 页码从0开始
    protected List<StockInfoDo> queryLimt(int page, int num) {
        int start = page * num;
        return baseInfoRepository.queryCN(start, num);
    }

    protected int queryCNTotal() {
        List<StockInfoDo> stockInfoDoList = baseInfoRepository.queryCN();
        return stockInfoDoList.size();
    }
}
